{extend name="base/base" /}
{block name="style"}
<style type="text/css">

</style>
{/block}
{block name="content"}
        <button onclick="cancel()" class="layui-btn layui-btn-primary">返回</button>
        <span style="font-size: 1em">资产信息：</span>
        <table id="table" lay-filter="table"></table> 

{/block}
{block name="script"}
<script>
layui.use('table', function(){
  var table = layui.table; 
  table.render({
  elem: '#table'
  ,id:'table'
  ,height: 'full-200'
  ,url: '/admin/user/balancelist?uid='+{$uid} //数据接口
  ,limit:20
  ,page: true //开启分页
  ,cols: [[ //表头
     {field:'username', title: '用户名', width: 200}
    ,{field:'wallet_name', title: '币种', width: 200}
    ,{field:'balance', title: '可用余额', width: 200}
    // ,{field:'freeze_balance', title: '理财冻结金额', width: 200}
    // ,{field:'retained', title: '最低留存数量', width: 200, edit: 'text'}
     ,{field:'change',title: '拨币（可用余额）', width: 200, edit: 'text'}
    ]]
  }); 
  ///监听单元格编辑
  table.on('edit(table)', function(obj){
    var value = obj.value //得到修改后的值
    ,data = obj.data //得到所在行所有键值
    ,field = obj.field; //得到字段
      // layer.prompt({title: '请输入拨币密码', formType: 0}, function(password, index){
        var post_data ={
          // 'password':password,
          id:data.id,
          field:field,
          amount:value
        };
    $.ajax({
            url:"{:url('admin/user/changBalance')}",
            type:"POST",
            data:post_data,
            success:function(ret){
                if (ret.code == 1) {
                  layer.msg('操作成功');
                  window.location.reload();
                }
                if (ret.code == 0) {
                    layer.msg(ret.msg);
                }
            }
        });
 // });
  });
});


  function cancel(){
    window.location.href=document.referrer;
  }
</script>
{/block}
